//
//  OosUserEntry.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 2/23/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosUserEntry.h"

@implementation OosUserName
+ (NSString *) extensionElementLocalName	{ return @"name"; }
@end

@implementation OosUserSurname
+ (NSString *) extensionElementLocalName	{ return @"surname"; }
@end

@implementation OosUserTelephone
+ (NSString *) extensionElementLocalName	{ return @"telephone"; }
@end

@implementation OosUserMail
+ (NSString *) extensionElementLocalName	{ return @"mail"; }
@end

#pragma mark Settings

@implementation OosNoMails
+ (NSString *) extensionElementLocalName	{ return @"nomails"; }
@end

@implementation OosNoNewletters
+ (NSString *) extensionElementLocalName	{ return @"nonewsletter"; }
@end

@implementation OosOnlyContacts
+ (NSString *) extensionElementLocalName	{ return @"onlycontacts"; }
@end

@implementation OosNoBulletins
+ (NSString *) extensionElementLocalName	{ return @"nobulletin"; }
@end

@implementation OosNoMailOnMediaComments
+ (NSString *) extensionElementLocalName	{ return @"nomailonmediacomments"; }
@end

@implementation OosNoMailOnLikes
+ (NSString *) extensionElementLocalName	{ return @"nomailonlikes"; }
@end

@implementation OosNoMailOnCommentsOnReview
+ (NSString *) extensionElementLocalName	{ return @"nomailoncommentsonreview"; }
@end

@implementation OosNoSuggestedContacts
+ (NSString *) extensionElementLocalName	{ return @"nosuggestedcontacts"; }
@end

@implementation OosFacebook
+ (NSString *) extensionElementLocalName	{ return @"facebook"; }
@end

@implementation OosTwitter
+ (NSString *) extensionElementLocalName	{ return @"twitter"; }
@end

@implementation OosFbCheckin
+ (NSString *) extensionElementLocalName	{ return @"bf-checkin"; }
@end


@implementation OosUserEntry

- (void) addExtensionDeclarations
{
	[super addExtensionDeclarations];
	
	Class entryClass = [self class];
	
	[self addExtensionDeclarationForParentClass: entryClass childClasses:
	 // Oos extensions
	 [OosAuthor class], [OosUserName class], [OosUserSurname class],
     [OosUserTelephone class], [OosNoMails class], [OosNoNewletters class], 
     [OosOnlyContacts class], [OosNoBulletins class], [OosNoMailOnMediaComments class], 
     [OosNoMailOnLikes class], [OosNoMailOnCommentsOnReview class], 
     [OosNoSuggestedContacts class], [OosUserMail class], [OosFacebook class], 
     [OosTwitter class], [OosFbCheckin class], nil];
}

- (OosAuthor *)oosAuthor
{
    return [self objectForExtensionClass:[OosAuthor class]];
}

- (void)setOosAuthor:(OosAuthor *)author
{
    [self addObject:author forExtensionClass:[OosAuthor class]];
}

- (NSString *) name
{
	return [[self objectForExtensionClass:[OosUserName class]] stringValue];
}

- (void)setName:(NSString *)name
{
    [self addObject:[OosUserName valueWithString:name] 
  forExtensionClass:[OosUserName class]];
}

- (NSString *) surname
{
	return [[self objectForExtensionClass:[OosUserSurname class]] stringValue];
}

- (void)setSurname:(NSString *)surname
{
    [self addObject:[OosUserSurname valueWithString:surname] 
  forExtensionClass:[OosUserSurname class]];
}

- (NSString *) telephone
{
	return [[self objectForExtensionClass:[OosUserTelephone class]] stringValue];
}

-(void)setTelephone:(NSString *)telephone
{
    
    [self addObject:[OosUserTelephone valueWithString:telephone] 
  forExtensionClass:[OosUserTelephone class]];
}

- (NSString *) mail
{
	return [[self objectForExtensionClass:[OosUserTelephone class]] stringValue];
}

- (void)setMail:(NSString *)mail
{
    [self addObject:[OosUserMail valueWithString:mail] 
  forExtensionClass:[OosUserMail class]];
}

- (BOOL)facebook
{
    return [[self objectForExtensionClass:[OosFacebook class]] boolValue];
}

- (BOOL)twitter
{
    return [[self objectForExtensionClass:[OosTwitter class]] boolValue];
}

- (BOOL)fbCheckin
{
    return [[self objectForExtensionClass:[OosFbCheckin class]] boolValue];
}

- (BOOL) receivesEmails
{
	return [self objectForExtensionClass:[OosNoMails class]] == nil;
}

- (BOOL) receivesNewsletters
{
	return [self objectForExtensionClass:[OosNoNewletters class]] == nil;
}

- (BOOL) receivesEmailsOnlyFromContacts
{
	return [self objectForExtensionClass:[OosOnlyContacts class]] == nil;
}

- (BOOL) receivesBulletins
{
	return [self objectForExtensionClass:[OosNoBulletins class]] == nil;
}

- (BOOL) receivesMailsOnMediaComments
{
	return [self objectForExtensionClass:[OosNoMailOnMediaComments class]] == nil;
}

- (BOOL) receivesMailsOnLikes
{
	return [self objectForExtensionClass:[OosNoMailOnLikes class]] == nil;
}

- (BOOL) receivesMailsOnCommentsOnReview
{
	return [self objectForExtensionClass:[OosNoMailOnCommentsOnReview class]] == nil;
}

- (BOOL) receivesSuggestedContacts
{
	return [self objectForExtensionClass:[OosNoSuggestedContacts class]] == nil;
}

@end
